package pl.edu.mimuw.mas.agent.behaviour.hunting.grouping;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import jade.core.AID;
import jade.lang.acl.ACLMessage;
import jade.lang.acl.MessageTemplate;
import pl.edu.mimuw.mas.agent.HuntingAgent;
import pl.edu.mimuw.mas.agent.behaviour.ServerBehaviour;

public class LeaderServerBehaviour extends ServerBehaviour {

	private static final long serialVersionUID = 1315320937981379749L;
	
	protected final Logger logger = LoggerFactory.getLogger(getClass());

	public LeaderServerBehaviour(HuntingAgent agent) {
		super(agent);
		
		MessageTemplate mt = MessageTemplate.MatchConversationId(HuntingAgent.GROUP_CONV);
		setMessageTemplate(mt);
	}

	@Override
	public boolean doAction(ACLMessage msg, ACLMessage reply) {
		HuntingAgent a = (HuntingAgent) myAgent;
		
		AID aid = msg.getSender();
		
//		logger.debug("{} : do mojej grupy dołącza {}", a.getName(), aid.getName());
		
		a.getGroup().add(aid);
			
		return false;
	}

}
